| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Matrix.h
1 // Matrix.h
3 //
5
6 namespace nkMaths
7 {
13 class Matrix
14 {
15 public :
16
21 Matrix () noexcept ;
33 Matrix (float m00, float m01, float m10, float m11) noexcept ;
50 Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) noexcept ;
73 Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) noexcept ;
79 Matrix (const Matrix& other) noexcept ;
80
81 // Getters
85 Vector getRow0 () const ;
89 Vector getRow1 () const ;
93 Vector getRow2 () const ;
97 Vector getRow3 () const ;
101 Vector getCol0 () const ;
105 Vector getCol1 () const ;
109 Vector getCol2 () const ;
113 Vector getCol3 () const ;
122 float get (unsigned int row, unsigned int col) const ;
123
124 // Setters
134 Matrix& set (float val, unsigned int row, unsigned int col) ;
135
136 // Alterations
140 Matrix getInverseMat2 () const ;
144 Matrix getInverseMat3 () const ;
148 Matrix getInverseMat4 () const ;
152 Matrix getTranspose () const ;
158 Matrix& inverseMat2 () ;
164 Matrix& inverseMat3 () ;
170 Matrix& inverseMat4 () ;
176 Matrix& transpose () ;
177
178 // Transformations
184 Vector getPositionComponent () const ;
190 Matrix getOrientationComponent () const ;
196 Vector getScaleComponent () const ;
204 void getDecomposed (Vector& position, Matrix& orientation, Vector& scale) const ;
205
214 Matrix& setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
227 Matrix& setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) ;
240 Matrix& setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) ;
247 Matrix& setPositionComponent (const Vector& position) ;
254 Matrix& setOrientationComponent (const Quaternion& rot) ;
261 Matrix& setScaleComponent (const Vector& scale) ;
270 Matrix& setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
271
272 // Utilities
276 float getDeterminantMat2 () const ;
280 float getDeterminantMat3 () const ;
284 float getDeterminantMat4 () const ;
288 float getTraceMat2 () const ;
292 float getTraceMat3 () const ;
296 float getTraceMat4 () const ;
297
301 nkMemory::String toString () const ;
309 Matrix& fromString (nkMemory::StringView str) ;
310
311 // Operators
318 Matrix& operator= (const Matrix& other) noexcept ;
325 bool operator== (const Matrix& other) ;
332 bool operator!= (const Matrix& other) ;
339 Matrix operator+ (const Matrix& other) const ;
345 void operator+= (const Matrix& other) ;
352 Matrix operator- (const Matrix& other) const ;
358 void operator-= (const Matrix& other) ;
365 Matrix operator* (const Matrix& other) const ;
372 Vector operator* (const Vector& vec) const ;
381 Quaternion operator* (const Quaternion& q) const ;
388 Matrix operator* (float scalar) const ;
394 void operator*= (const Matrix& other) ;
400 void operator*= (float scalar) ;
407 Matrix operator/ (float scalar) const ;
413 void operator/= (float scalar) ;
414
415 public :
416
417 // Attributes
418 float _m [4][4] ;
419 } ;
420 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::fromString
Matrix & fromString(nkMemory::StringView str)
nkMaths::Matrix::setToPerspectiveMatrix
Matrix & setToPerspectiveMatrix(float fov, float aspect, float nearVal, float farVal)
nkMaths::Matrix::toString
nkMemory::String toString() const
nkMaths::Matrix::getTraceMat2
float getTraceMat2() const
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::setOrientationComponent
Matrix & setOrientationComponent(const Quaternion &rot)
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::setScaleComponent
Matrix & setScaleComponent(const Vector &scale)
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix::_m
float _m[4][4]
The matrix memory, considered in row-major order (_m[row][col]).
Definition: Matrix.h:418
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::setToViewMatrixDirection
Matrix & setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::setPositionComponent
Matrix & setPositionComponent(const Vector &position)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::setToOrthographicMatrix
Matrix & setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float nearVal, float farVal)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Matrix &orientation, Vector &scale) const
nkMaths::Matrix::setToTransformation
Matrix & setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::Matrix
Matrix() noexcept
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::set
Matrix & set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7